package com.tarena.lbs.basic.dao.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tarena.lbs.basic.dao.mapper.AreaMapper;
import com.tarena.lbs.basic.dao.repository.AreaRepository;
import com.tarena.lbs.basic.pojo.po.AreaPO;
import com.tarena.lbs.basic.pojo.vo.AreaVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class AreaRepositoryImpl implements AreaRepository {
    @Autowired
    private AreaMapper areaMapper;
    @Override
    public List<AreaPO> queryProvinces() {
        QueryWrapper<AreaPO> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("depth",1);

        return areaMapper.selectList(queryWrapper);
    }

    @Override
    public List<AreaPO> queryChild(Long parentId) {
        QueryWrapper<AreaPO> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("parent_id",parentId);
        return areaMapper.selectList(queryWrapper);
    }

    @Override
    public List<AreaPO> queryChildren(Integer parentId) {
        QueryWrapper<AreaPO> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("parent_id",parentId);
        return areaMapper.selectList(queryWrapper);
    }
}
